﻿using System;
using System.Data;
using Dapper;
using Demo.Model;

namespace Demo.Server
{
    public class DeptServer:IDeptServer
    {
        public DeptServer()
        {
        }

        public string GetNameById(int id)
        {
            using (IDbConnection conn = DataBaseConfig.GetSqlConnection())
            {
                try
                {
                    string querySql = @"SELECT *
                                      FROM [RRIS].[dbo].[Dict_Dept]
                                     WHERE DeptID = @Id";
                    return conn.QueryFirstOrDefault<Dict_Dept>(querySql, new { Id = id }).DeptName;
                }
                catch(Exception ex)
                {
                    string aa = ex.Message.ToString();
                    return "";
                }

            }
        }
    }
}
